package com.itsitio.dbimporter.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

/**
 * BaseController	
 * @author 
 *
 */

public class BaseController {

	protected ModelAndView forward(String view, Map<String, Object> model){
		model.put("body", "/WEB-INF/pages/"+view+".jsp");
		return new ModelAndView("includes/Template", model);
	}
	
	protected ModelAndView forwardSinFrame(String view, Map<String, Object> model){
		return new ModelAndView(view, model);
	}
	
	protected ModelAndView forward(String url, Long idPostulante, String tipoDato, Map<String, Object> model)
	{
		
		if(url.equals("/mcs/usuario/agregarPerfil.do"))
		{
			return new ModelAndView(new RedirectView(url+idPostulante), model);
		}
		else
			return new ModelAndView("includes/Template", model);
	
	}
//		if(url.equals("/mcs/postulante/verDatosPostulante.do?idPostulante="))
//		{
//			return new ModelAndView(new RedirectView(url+idPostulante), model);
//		}
//		else if(url.equals("/mcs/usuario/home.do"))
//		{
//			return new ModelAndView(new RedirectView(url), model);
//		}
//		else if(url.equals("/mcs/usuario/registrarForm.do"))
//		{
//			return new ModelAndView(new RedirectView(url), model);
//		}
//		else if(url.equals("/mcs/dato/altaDatosForm.do?tipoDato="))
//		{
//			return new ModelAndView(new RedirectView(url+tipoDato), model);
//		}
//		else
//			return new ModelAndView("includes/Template", model);
//		
//	}
	
	protected ModelAndView forward(String view){
		Map<String, Object> model = new HashMap<String, Object>();
		return forward(view, model);
	}
//	
//	
	protected ModelAndView forwardHtml(String view, Map<String, Object> model){
		model.put("body", "/WEB-INF/pages/"+view+".html");
		return new ModelAndView("includes/Template", model);
	}
//	
	protected ModelAndView forwardHtml(String view){
		Map<String, Object> model = new HashMap<String, Object>();
		return forwardHtml(view, model);
	}
//	
//	
	protected Map<String, Object> createModel(){
		return new HashMap<String, Object>();
	}

	
}
